﻿using System.Threading.Tasks;
using SmartCity.Shared;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace MetroManagement
{
    /// <summary>
    /// 城市应用服务类
    /// </summary>
    public class CityAppService : ApplicationService, ICityAppService
    {
        private readonly IRepository<City, int> _cityRepository;

        public CityAppService(
            IRepository<City, int> cityRepository)
        {
            _cityRepository = cityRepository;
        }

        // 获取
        public async Task<ResultResponse<CityDto>> GetAsync()
        {
            var city = await _cityRepository.FirstOrDefaultAsync();
            var dto = ObjectMapper.Map<City, CityDto>(city);
            return ResultResponse<CityDto>.Successful(dto);
        }
    }
}